#include <stdio.h>
#include "Qstack.h"
// 示例
typedef char locktype;
locktype muc[QSTACKBUFF_SIZE]; // 互斥锁数组
void mLock(int i)
{
    printf("%d号上锁\n", i);
}
void mULock(int i)
{
    printf("%d号解锁\n", i);
}
#if 1 // 测试示例
int main(void)
{
    // 初始化
    QstackStructType cb0;
    QstackStructType cb1;
    QstackStructType cb2;
    char data = 0;
    QstackRegister(mLock, mULock);
    QstackInit(&cb0); // 初始化队列0
    QstackInit(&cb1); // 初始化队列1
    QstackInit(&cb2); // 初始化队列2
    QstackWrite(&cb0, '1', 0);
    QstackWrite(&cb0, '2', 0);
    QstackWrite(&cb0, '3', 0);
    QstackWrite(&cb0, '4', 0);
    QstackWrite(&cb0, '5', 0);
    QstackWrite(&cb0, '6', 0);

    QstackWrite(&cb1, '1', 1);
    QstackWrite(&cb1, '2', 1);
    QstackWrite(&cb1, '3', 1);
    QstackWrite(&cb1, '4', 1);
    QstackWrite(&cb1, '5', 1);
    QstackWrite(&cb1, '6', 1);

    QstackWrite(&cb2, '1', 2);
    QstackWrite(&cb2, '2', 2);
    QstackWrite(&cb2, '3', 2);
    QstackWrite(&cb2, '4', 2);
    QstackWrite(&cb2, '5', 2);
    QstackWrite(&cb2, '6', 2);

    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);

    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);


    QstackRead(&cb0, &data, 0);
    printf("队列0 data = %c\n", data);
    QstackRead(&cb1, &data, 1);
    printf("队列1 data = %c\n", data);
    QstackRead(&cb2, &data, 2);
    printf("队列2 data = %c\n", data);
    
    return 0;
}
#endif

